import {GET_currentDeptInfo} from './type';
import {currentDeptInfo} from '../../api/depatmentInfo';
export default {
  [GET_currentDeptInfo]({commit},pageNum, pageSize){
    currentDeptInfo(pageNum, pageSize).then(function(data){
      let item = data[0];
      let dataCount = parseInt(item.count);
      let totalPage = Math.floor((dataCount + pageSize - 1) / pageSize);
      let prePage = currentPage > 1 ? currentPage - 1 : 1
      let nextPage = currentPage < totalPage ? currentPage + 1 : totalPage;
      let isFirst = currentPage <= 1;
      let isLast = currentPage >= totalPage;
      userInfo.deptPage = {
        currentPage: currentPage,
        pageSize: pageSize,
        dataCount: dataCount,
        totalPage: totalPage,
        prePage: prePage,
        nextPage: nextPage,
        isFirst: isFirst,
        isLast: isLast
      };
      commit(GET_currentDeptInfo,data);
      document.querySelectorAll('#deptLoading')[0].style.display = 'none';
    });
  }
}
